//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_pllbupdater.sqf"
#include "xr_macros.sqf"

disableSerialization;
#define __lbctrl (__uiGetVar(GVARXR(UnconDlg)) displayCtrl 1000)
while {GVARXR(lb_u_updater)} do {
	if (!isNil {__uiGetVar(GVARXR(UnconDlg))} && {ctrlShown __lbctrl}) then {
		lbClear __lbctrl;
		{
			_u = __getMNsVar2(_x);
			if (!isNil "_u" && {!isNull _u} && {alive _u} && {side (group _u) == side (group player)} && {_u != player} && {_u distance player <= GVARXR(near_player_dist)}) then {
				if !(_u getVariable [QGVARXR(pluncon), false]) then {
					__lbctrl lbAdd (name _u);
				};
			};
		} forEach GVARXR(player_entities);
	};
	if (!GVARXR(lb_u_updater)) exitWith {};
	sleep 0.5;
};